package org.libcsp.generic.api.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.libcsp.generic.api.support.i18n.I18NTranslate;

@Getter
@AllArgsConstructor
@NoArgsConstructor
public class E {

    private String name;

    private int code;
    private String msg;

    public static final E SUCCESS = E.of(IEnum.OK);
    public static final E FAILURE = E.of(IEnum.BAD_REQUEST);
    public static E of(IEnum e, String... params) {
        return new E(e.name(), e.code(), I18NTranslate.of(e.msg(), params));
    }

    public static E of(IEnum e) {
        return new E(e.name(), e.code(), I18NTranslate.of(e.msg(), null));
    }
}
